package com.golxen.framework.user.log;


import com.golxen.framework.db.DBManager;
import com.golxen.framework.db.dao.AbstractDaoImpl;
import com.golxen.framework.user.log.entity.LogLogin;

import java.sql.Types;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class LogLoginDaoImpl extends AbstractDaoImpl {

    public boolean addLogLoginList(List<LogLogin> list) {
        boolean result = false;
        getDb().setConnName(DBManager.logDbName);
        String sql = "INSERT INTO t_l_login(userId,time,type) VALUES(?,?,?)";

        List<Map<Integer, Object>> mapList = new ArrayList<>();
        for (LogLogin info : list) {
            Map<Integer, Object> para = new HashMap<>();
            int i = 1;
            para.put(i++, info.getUserId());
            para.put(i++, info.getTime());
            para.put(i++, info.getType());
            mapList.add(para);
        }

        if (getDb().executeBatchQuery(sql, mapList) > -1) {
            result = true;
        }
        return result;
    }


}
